package com.zhengdongzulin.zuke.app.main.mine.contract

import androidx.lifecycle.rxLifeScope
import com.lxj.androidktx.livedata.StateLiveData
import com.zhengdongzulin.zuke.app.Api
import com.zhengdongzulin.zuke.app.data.ContractListData
import com.zhengdongzulin.zuke.base.BaseViewModel
import rxhttp.wrapper.param.RxHttp
import rxhttp.wrapper.param.toResponse

class MyContractVm : BaseViewModel() {

    var list_house_contract: StateLiveData<MutableList<ContractListData>> = StateLiveData()

    fun list_house_contract(id: String) {
        rxLifeScope.launch(
            {
                var r = RxHttp.postJson(Api.LIST_HOUSE_CONTRACT)
                    .add("houseId", id)
                    .toResponse<MutableList<ContractListData>>()
                    .await()
                list_house_contract.postValueAndSuccess(r)
            }, {
                assignment(it, list_house_contract)
            }
        )
    }

}